package com.easylinkin.linkappapi.quality.controller;

import com.easylinkin.linkappapi.quality.service.QualityConfigService;
import com.easylinkin.linkappapi.quality.entity.QualityConfig;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.util.Assert;
import org.springframework.web.bind.annotation.*;
import site.morn.rest.RestBuilders;
import site.morn.rest.RestMessage;

/**
 * @author: kan yuanfeng
 * @Date: 2023/04/04 11:42
 * @Description: 质量通知设置管理
 */
@RestController
@RequestMapping("qualityConfig")
@Api(tags = "质量通知设置管理")
public class QualityConfigController {

    @Autowired
    private QualityConfigService qualityConfigService;

    /**
     * @Description: 增加通知设置
     * @author kan yuanfeng
     * @date 2023/04/04 11:42
     */
    @PostMapping
    @ApiOperation("增加通知设置")
    public RestMessage insert(@RequestBody QualityConfig qualityConfig){
        qualityConfigService.insert(qualityConfig);
        return RestBuilders.successBuilder().build();
    }

    /**
     * @Description: 编辑通知设置
     * @author kan yuanfeng
     * @date 2023/04/04 11:42
     */
    @PutMapping
    @ApiOperation("编辑通知设置")
    public RestMessage updateById(@RequestBody QualityConfig qualityConfig){
        Assert.notNull(qualityConfig.getId(),"id不能为空");
        qualityConfigService.updateOne(qualityConfig);
        return RestBuilders.successBuilder().build();
    }

    /**
     * @Description: 查询通知设置详情
     * @author kan yuanfeng
     * @date 2023/04/04 11:42
     */
    @GetMapping
    @ApiOperation("查询通知设置详情")
    public RestMessage findOne() {
        QualityConfig qualityConfig = qualityConfigService.findOne();
        return RestBuilders.successBuilder().data(qualityConfig).build();
    }
}

